import shutil
import os
from datetime import datetime
def clear_folder(folder_path):
    for filename in os.listdir(folder_path):
        file_path = os.path.join(folder_path, filename)
        try:
            if os.path.isfile(file_path) or os.path.islink(file_path):
                os.unlink(file_path)
            elif os.path.isdir(file_path):
                shutil.rmtree(file_path)
        except Exception as e:
            print(f'Failed to delete {file_path}. Reason: {e}')
def change_folder_permissions(folder_path, mode):
    try:
        os.chmod(folder_path, mode)
        print(f"Successfully changed permissions of {folder_path} to {oct(mode)}")
    except Exception as e:
        print(f"Failed to change permissions of {folder_path}. Reason: {e}")
def zip_folder(folder_path, output_filename):
    try:
        shutil.make_archive(output_filename, 'zip', folder_path)
        print(f"Successfully compressed {folder_path} to {output_filename}.zip")
    except Exception as e:
        print(f"Failed to compress {folder_path}. Reason: {e}")
def get_unique_filename():
    timestamp = datetime.now().strftime("%Y%m%d%H%M%S%f")
    return f"{timestamp}"             
if __name__ == '__main__':
    data_folder = 'data'
    clear_folder(data_folder)